import 'package:flutter/material.dart';
import 'package:xinxuan/common/button_util.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class SeckillOrderBtns extends StatelessWidget {

  /// 状态
  final int status;
  /// 确认收货按钮是否可点击
  final int isClick;
  /// 去支付
  final Function toPayFun;
  /// 取消订单
  final Function cleanOrderFun;
  /// 在线客服
  final Function? customerServiceFun;
  /// 物流信息
  final Function? logisticsFun;
  /// 确认收货
  final Function confirmReceiptFun;
  /// 按钮宽度
  final double btnWidth;

  SeckillOrderBtns({
    required this.status, 
    required this.toPayFun, 
    required this.cleanOrderFun, 
    required this.confirmReceiptFun, 
    this.customerServiceFun,
    this.logisticsFun,
    this.btnWidth = 90,
    this.isClick = 0
  });

  @override
  Widget build(BuildContext context) {
    List<Widget> widgets = [];
    if (status == 1) {
      widgets = [
        Container(
          width: btnWidth.w,
          margin: EdgeInsets.only(left: 12.w),
          child: ButtonUtil(
            text: '取消订单', 
            fontSize: 14.w, 
            borderRadius: 18.w, 
            height: 36.h, 
            textColor: textSubtitleColor,
            showBorder: true,
            borderColor: bgDisplayColor,
            bgColors: [
              bgWhiteColor,
              bgWhiteColor,
            ],
            onTop: () => cleanOrderFun()
          ),
        ),
        Container(
          width: btnWidth.w,
          margin: EdgeInsets.only(left: 12.w),
          child: ButtonUtil(
            text: '去支付', 
            fontSize: 14.w, 
            borderRadius: 18.w, 
            height: 36.h, 
            onTop: () => toPayFun()
          ),
        )
      ];
    } else if (status == 5) {
      widgets = [
        Container(
          width: btnWidth.w,
          margin: EdgeInsets.only(left: 12.w),
          child: ButtonUtil(
            text: '物流信息', 
            fontSize: 14.w, 
            borderRadius: 18.w, 
            height: 36.h, 
            textColor: mainTextColor,
            showBorder: true,
            bgColors: [
              bgWhiteColor,
              bgWhiteColor,
            ],
            onTop: () => logisticsFun!()
          ),
        ),
        isClick == 0 ? Container(
          width: btnWidth.w,
          margin: EdgeInsets.only(left: 12.w),
          child: ButtonUtil(
            text: '确认收货', 
            fontSize: 14.w, 
            borderRadius: 18.w, 
            height: 36.h, 
            textColor: textSubtitleColor,
            bgColors: [
              bgDisplayColor,
              bgDisplayColor,
            ],
            onTop: () {}
          ),
        ) : Container(
          width: btnWidth.w,
          margin: EdgeInsets.only(left: 12.w),
          child: ButtonUtil(
            text: '确认收货', 
            fontSize: 14.w, 
            borderRadius: 18.w, 
            height: 36.h, 
            onTop: () => confirmReceiptFun()
          ),
        )
      ];
    } else if (status == 8) {
      widgets = [
        Container(
          width: btnWidth.w,
          margin: EdgeInsets.only(left: 12.w),
          child: ButtonUtil(
            text: '在线客服', 
            fontSize: 14.w, 
            borderRadius: 18.w, 
            height: 36.h, 
            textColor: mainTextColor,
            showBorder: true,
            bgColors: [
              bgWhiteColor,
              bgWhiteColor,
            ],
            onTop: () => customerServiceFun!()
          ),
        ),
        Container(
          width: btnWidth.w,
          margin: EdgeInsets.only(left: 12.w),
          child: ButtonUtil(
            text: '物流信息', 
            fontSize: 14.w, 
            borderRadius: 18.w, 
            height: 36.h, 
            onTop: () => logisticsFun!()
          ),
        )
      ];
    }
    return Row(
      mainAxisAlignment: MainAxisAlignment.end,
      children: widgets,
    );
  }
}